import {DatePicker} from "antd";
import {CommonComponentProps} from "../../../../../components/editor/interface.ts";
import {useDrag} from "react-dnd";
import FormItem from "antd/es/form/FormItem";
import {CSSProperties} from "react";
import {removeSetter} from "../../../../utils/removeSetter.ts";
import {MoveDrop} from "../../../../hooks/useMoveDrop.tsx";

export interface DatePickerProps extends CommonComponentProps {
    id: number;
    name: string;
    styles?: CSSProperties;
    parentId: number;
    children?: any;
    label:string
    type: any
    options:any
}

const DatePickerDev = (props:DatePickerProps) => {
    const {id,name,styles} = props;
    const [_,drag] = useDrag({
        type:"DatePicker",
        item:{
            type:name,
            id,
            dragType:"move"
        }
    })
    const ComponentProps = removeSetter({...props},["children","parentId"])

    return (
        <div className={'relative'}  ref={drag}  data-component-id={id}>
            <MoveDrop key={name} dropComponentId={id} parentId={props.parentId}  />
            <FormItem >
                <FormItem  label={props.label} name={props.name} rules={props.rule} style={{margin:"0",...styles}}>
                    <DatePicker {...ComponentProps}  />
                </FormItem>
            </FormItem>

        </div>
    );
};

export default DatePickerDev;